﻿using System.Web.UI.WebControls;
using HNAlbum.Helper;
using HNAlbum.Logic.Entity;

namespace HNAlbum.Component.AlbumGallery
{
    /// <summary>
    /// Display class of a HNAlbumData instance
    /// </summary>
    public class DashboardItem : Panel
    {
        #region Properties
        #endregion
        /// <summary>
        /// Build the dashboard item
        /// </summary>
        /// <param name="albumData">The data object</param>
        public DashboardItem(HNAlbumData albumData)
        {
            //Set default attributes
            this.Attributes.Add("class", "album");
            this.Attributes.Add("onclick", string.Format("window.location.href='Album.aspx?id={0}'", albumData.Id));

            //Cover image
            Image imgCover = new Image();
            imgCover.ImageUrl = albumData.CoverImageUrl;
            this.Controls.Add(imgCover);

            //Album name
            Label lblName = new Label();
            lblName.Text = string.Format("{0} photo(s)", albumData.AlbumInfo.PhotoCount);
            lblName.Attributes.Add("class", "name");
            this.Controls.Add(lblName);
        }
    }
}